package cn.javacv.gulimall.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ElasticSearchConfig {
    public static final RequestOptions COMMON_OPTIONS;
    @Bean
    public RestHighLevelClient esClient(){
        RestClientBuilder restClientBuilder = null;
        restClientBuilder = RestClient.builder(new HttpHost("javacv.cn", 19200, "http"));
        RestHighLevelClient client = new RestHighLevelClient(restClientBuilder);
//        RestHighLevelClient client = new RestHighLevelClient(
//                RestClient.builder(
//                        new HttpHost("javacv.cn", 19200, "http")));
        return client;
    }

    static {
        RequestOptions.Builder builder = RequestOptions.DEFAULT.toBuilder();
//            builder.addHeader("Authorization", "Bearer " + TOKEN);
//            builder.setHttpAsyncResponseConsumerFactory(
//                    new HttpAsyncResponseConsumerFactory
//                            .HeapBufferedResponseConsumerFactory(30 * 1024 * 1024 * 1024));
        COMMON_OPTIONS = builder.build();
    }


}
